package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.TicketTime;
import cn.icanci.ladybird.dao.TicketTimeDao;
import cn.icanci.ladybird.service.TicketTimeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TicketTime)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:45:02
 */
@Service("ticketTimeService")
public class TicketTimeServiceImpl implements TicketTimeService {
    @Resource
    private TicketTimeDao ticketTimeDao;

    /**
     * 通过ID查询单条数据
     *
     * @param ticketTimeId 主键
     * @return 实例对象
     */
    @Override
    public TicketTime queryById(Long ticketTimeId) {
        return this.ticketTimeDao.queryById(ticketTimeId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketTime> queryAllByLimit(int offset, int limit) {
        return this.ticketTimeDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketTime 实例对象
     * @return 实例对象
     */
    @Override
    public TicketTime insert(TicketTime ticketTime) {
        this.ticketTimeDao.insert(ticketTime);
        return ticketTime;
    }

    /**
     * 修改数据
     *
     * @param ticketTime 实例对象
     * @return 实例对象
     */
    @Override
    public TicketTime update(TicketTime ticketTime) {
        this.ticketTimeDao.update(ticketTime);
        return this.queryById(ticketTime.getTicketTimeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ticketTimeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long ticketTimeId) {
        return this.ticketTimeDao.deleteById(ticketTimeId) > 0;
    }
}